﻿using System.Text;
using Shop.RemoteModel.Coupon.Model;
using WeDonekRpc.Helper;

namespace Shop.Collect.Linq
{
    internal static class CouponLinq
    {
        public static string GetCouponShow (this CouponSet set)
        {
            StringBuilder str = new StringBuilder();
            set.Discount.ForEach(c =>
            {
                if (set.CouponType == RemoteModel.CouponType.满减)
                {
                    str.AppendFormat("满{0}元减{1}元。\n", c.ThresholdPrice, c.CouponVal.Value);
                }
                else
                {
                    str.AppendFormat("满{0}元打{1}折。\n", c.ThresholdPrice, c.Discount.Value / 10.0);
                }
            });
            str.Remove(str.Length - 1, 1);
            return str.ToString();
        }
    }
}
